1 // Equipo Poncho, Carriel y Ruana
23 template <class T
> string
toStr(const T
&x
)
24 { stringstream s
; s
<< x
; return s
.str(); }
25 template <class T
> int toInt(const T
&x
)
26 { stringstream s
; s
<< x
; int r
; s
>> r
; return r
; }
28 #define For(i, a, b) for (int i=(a); i<(b); ++i)
29 #define foreach(x, v) for (typeof (v).begin() x = (v).begin(); x != (v).end(); ++x)
30 #define D(x) cout << #x " = " << (x) << endl;
32 const double EPS
= 1e-9;
34 int cmp(double x
, double y
= 0, double tol
= EPS
) {
35 return (x
<= y
+ tol
) ? (x
+ tol
< y
) ? -1 : 0 : 1;
40 while (cin
>> n
>> m
) {
41 if (n
== 0 and m
== 0) break;
43 vector
<long long> grad(k
+ 1);
44 for (int i
= 0; i
< k
+ 1; ++i
) {
47 long long mod
= n
+ 1;
48 //assert(grad.size() == k + 1);
50 for (long long x
= 0; x
<= m
; x
++){
53 for (int i
= 0; i
< grad
.size(); ++i
) {
54 //printf(" y = y + %d\n", grad[i] * d);
55 y
+= ((grad
[i
] % mod
) * d
) % mod
;
57 d
= (d
* (x
% mod
)) % mod
;
60 //printf("added %d\n", y % mod);
62 cout
<< ans
.size() << endl
;